package com.melesta.payment.sms;

import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Handler;
import android.telephony.SmsManager;
import android.util.Log;
import com.melesta.engine.Error;
import com.melesta.payment.PaymentManager;
import com.melesta.payment.PaymentTransaction;
import com.melesta.payment.interfaces.IListener;
import com.melesta.payment.interfaces.IRequestBuilder;
import com.melesta.payment.interfaces.ISystem;

public class SmsSystem
  implements ISystem
{
  static final String SYSTEM_NAME = "sms";
  private Context context;
  private IListener defaultListener;

  private void updateContext(Context paramContext)
  {
    this.context = paramContext;
  }

  public Object get(String paramString)
  {
    return null;
  }

  public IListener getDefaultListener()
  {
    return this.defaultListener;
  }

  public String getName()
  {
    return "sms";
  }

  public IRequestBuilder getRequestBuilder()
  {
    return new SmsRecuestBuilder(this);
  }

  public boolean onActivityResult(Context paramContext, int paramInt1, int paramInt2, Intent paramIntent)
  {
    return false;
  }

  public void onCreate(Context paramContext, Handler paramHandler)
  {
    updateContext(paramContext);
  }

  public void onDestroy(Context paramContext, Handler paramHandler)
  {
    updateContext(paramContext);
  }

  public void onPause(Context paramContext, Handler paramHandler)
  {
    updateContext(paramContext);
  }

  public void onResume(Context paramContext, Handler paramHandler)
  {
    updateContext(paramContext);
  }

  public void onStart(Context paramContext, Handler paramHandler)
  {
    updateContext(paramContext);
  }

  public void onStop(Context paramContext, Handler paramHandler)
  {
    updateContext(paramContext);
  }

  public void purchaseProcessed(PaymentTransaction paramPaymentTransaction)
  {
  }

  public void sendSms(final String paramString1, String paramString2, String paramString3)
  {
    Log.d("payment", "begin sms (" + paramString3 + ") to " + paramString2);
    try
    {
      Intent localIntent = new Intent("SMS_SENT");
      PendingIntent localPendingIntent = PendingIntent.getBroadcast(this.context, 0, localIntent, 0);
      this.context.registerReceiver(new BroadcastReceiver()
      {
        public void onReceive(Context paramAnonymousContext, Intent paramAnonymousIntent)
        {
          Log.d("SMS INFO DATA", getResultData());
          Log.d("SMS INFO CODE", getResultCode() + "");
          Log.d("SMS INFO STR", toString());
          int i = getResultCode();
          String str = getResultData();
          PaymentManager.getInstance().postResponse(new SmsResponse().setName(paramString1).setCode(i).setData(str).setListener(SmsSystem.this.defaultListener));
          SmsSystem.this.context.unregisterReceiver(this);
        }
      }
      , new IntentFilter("SMS_SENT"));
      SmsManager.getDefault().sendTextMessage(paramString2, null, paramString3, localPendingIntent, null);
      return;
    }
    catch (Exception localException)
    {
      Error.processException("payment - sendSms", localException);
    }
  }

  public SmsSystem set(String paramString, Object paramObject)
  {
    return this;
  }

  public void setDefaultListener(IListener paramIListener)
  {
    this.defaultListener = paramIListener;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.melesta.payment.sms.SmsSystem
 * JD-Core Version:    0.6.2
 */